<template>
  <el-dialog
    :title="title"
    destroy-on-close
    append-to-body
    :visible.sync="show"
    width="1000px"
    :before-close="cancel">
    <el-table ref="TableRef" :data="tabelDeta">
      <el-table-column show-overflow-tooltip :label="$t('订单号')" align="center" prop="orderNo" />
      <el-table-column :label="$t('sku编号')" align="center" width="110" prop="skuNo"> </el-table-column>
      <el-table-column show-overflow-tooltip :label="$t('sku申请id')" align="center" prop="applyId" />
      <el-table-column show-overflow-tooltip :label="$t('申请时价格')" align="center" prop="applyPrice">
        <template #default="{ row }">
          {{ row.applyPrice ? (+row.applyPrice).toFixed() : '' }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('云价格')" width="110" align="center" prop="cloudPrice">
        <template #default="{ row }">
          {{ row.cloudPrice ? (+row.cloudPrice).toFixed() : '' }}
        </template>
      </el-table-column>
      <el-table-column
        show-overflow-tooltip
        :label="$t('需要付款的数量')"
        align="center"
        prop="handleWaitPayNum" />
      <el-table-column
        show-overflow-tooltip
        :label="$t('提前付款的数量')"
        align="center"
        prop="handlePayNum" />
      <el-table-column show-overflow-tooltip :label="$t('卖家支付数量')" align="center" prop="handleNum" />
      <el-table-column show-overflow-tooltip :label="$t('卖家付款总价')" align="center" prop="waitPayTotal">
        <template #default="{ row }">
          {{ row.waitPayTotal ? (+row.waitPayTotal).toFixed() : '' }}
        </template>
      </el-table-column>
      <el-table-column width="110" :label="$t('平台付给供应商的钱')" align="center" prop="platPayDistrFee">
        <template #default="{ row }">
          {{ row.platPayDistrFee ? (+row.platPayDistrFee).toFixed() : '' }}
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip :label="$t('供应商')" align="center" prop="distrName" />
      <el-table-column show-overflow-tooltip :label="$t('收取总数')" align="center" prop="platProfitTotal">
        <template #default="{ row }">
          {{ row.platProfitTotal ? (+row.platProfitTotal).toFixed() : '' }}
        </template>
      </el-table-column>
    </el-table>
  </el-dialog>
</template>
<script>
import handleTableSum from '@/utils/handleSum'

import { billSellerFeeInfo } from '@/api/bill/seller'
export default {
  activated() {
    this.$nextTick(() => this.$refs['TableRef']?.doLayout())
  },
  props: {
    data: {
      type: Object,
      default: () => {},
    },
    title: {
      type: String,
    },
    /**
     * 控制显示隐藏
     */
    show: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      tabelDeta: [],
    }
  },
  methods: {
    handleSum(param) {
      /**
       * 需要进行统计的字段
       */
      const data = handleTableSum(param, ['turnover', 'commission'], '合计', 0)
      console.log(`data ==>`, JSON.parse(JSON.stringify(data)))
      return data
    },

    cancel() {
      console.log('执行了')
      this.$emit('update:show', false)
    },
  },
  watch: {
    show: function (params) {
      if (params) {
        billSellerFeeInfo({ id: this.data.id, type: 5 }).then((res) => {
          this.tabelDeta = res.data.orderSkuSellerApplyList
        })
      }
    },
  },
}
</script>
